<?php
// No direct access
defined('_JEXEC') or die;

$dbPrefix = $this->component->dbprefix;
$tables = GenCodeHelper::getTables();
?>

<div id="default-form">
	<ul id="select-table-container">
		<li id="list-select-table">
			<label>Select Table</label>
			<select id="table_id" name="jform[table_id]">
				<option value="">- Select -</option>
				<?php foreach ($this->tables as $table): ?>
				<?php $selected = ($table->id == $this->item->table_id) ? 'selected="selected"' : null; ?>
				<option value="<?php echo $table->id; ?>" <?php echo $selected; ?>><?php echo $dbPrefix . $table->name; ?></option>
				<?php endforeach; ?>
			</select>
		</li>
		<?php 
		$filter = unserialize($this->item->fields_to_filter);
		
		$checkCategory = isset($filter['category']) ? 'checked="checked"' : null;
		$catValue = isset($filter['catid']) ? $filter['catid'] : null;
		?>
		<li class="filter">
			<label>
				<span style="float: left; width: 120px;">Check permission with category:</span>
			</label>
			<input type="checkbox" name="jform[fields_to_filter][category]" value="1" <?php echo $checkCategory; ?> /> <span style="float: left; line-height: 25px; margin-right: 5px;">Category (Field ID:</span>
			<input type="text" size="10" name="jform[fields_to_filter][catid]" title="Field category id in table" value="<?php echo $catValue; ?>" />
			<span style="float: left; line-height: 25px;">)</span>
		</li>
		<li>
			<label>&nbsp;</label>
			<div id="list-table-fields" style="float: left; width: 800px; border: 1px solid #CCC; padding: 5px;">
				Select table
			</div>
		</li>
	</ul>
	
	<input type="hidden" name="edit_mode" value="form" />
</div>
